 var http_request = false;  
 //向服务器发起XMLHTTP请求。  
 function sendRequest(url,param,remoteCall) {//初始化、指定处理函数、发送请求的函数  
     http_request = false;  
     //开始初始化XMLHttpRequest对象  
     if(window.XMLHttpRequest) { //Mozilla 浏览器  
         http_request = new XMLHttpRequest();  
         if (http_request.overrideMimeType) {//设置MiME类别  
             http_request.overrideMimeType('text/xml');  
         }  
     }  
     else if (window.ActiveXObject) { // IE浏览器  
         try {  
             http_request = new ActiveXObject("Msxml2.XMLHTTP");  
         } catch (e) {  
             try {  
                 http_request = new ActiveXObject("Microsoft.XMLHTTP");  
             } catch (e) {}  
         }  
     }  
     if (!http_request) { // 异常，创建对象实例失败  
         window.alert("不能创建XMLHttpRequest对象实例.");  
         return false;  
     }  
     http_request.onreadystatechange = remoteCall;  
     // 确定发送请求的方式和URL以及是否同步执行下段代码  
     http_request.open("post", url, true);         
     http_request.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
     http_request.send(encodeURI(param));  
 }  

//用户使用的发送请求的公共方法
var frmName = "";
function remoteCallForHksp(url, method, param, callback,frm){
  frmName = frm;
  REMOTE_URL = url;
  paction = url;
  REMOTE_METHOD = method;
  REMOTE_PARAM = param;
  pparam = param;
  if(callback!=null){
  	REMOTE_CALLBACK = callback;
  }else{
  	REMOTE_CALLBACK = recall;
  }
  showLoadingDivRk();
  window.setTimeout("doRemoteCallForHksp()", 1);
}

//发送xmlhttp请求
function doRemoteCallForHksp(){
    REMOTE_METHOD = REMOTE_METHOD||"post";
    REMOTE_PARAM = REMOTE_PARAM||"";
    try{
         HTTPXML_REQUEST = new ActiveXObject("Microsoft.XMLHTTP");
         REMOTE_PARAM = encodeURI(REMOTE_PARAM);
         HTTPXML_REQUEST.onreadystatechange = remoteCallStateChangedForHksp;
         HTTPXML_REQUEST.open(REMOTE_METHOD, REMOTE_URL, true);
         HTTPXML_REQUEST.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
         HTTPXML_REQUEST.send(REMOTE_PARAM);
    }
    catch (e){alert(e);}
}


//回调函数
function remoteCallStateChangedForHksp(){
   if (HTTPXML_REQUEST.readyState == 4){
      var xml = HTTPXML_REQUEST.responseText;
      var doc = new ActiveXObject("Msxml2.DOMDocument.3.0");
      doc.loadXML(xml);       
      setFrmValueByKeys(frmName,doc);
      hideLoadingDivRk();
      HTTPXML_REQUEST = null;
      REMOTE_URL = "";
      REMOTE_METHOD = "";
      REMOTE_PARAM = "";
      if (REMOTE_CALLBACK != null) REMOTE_CALLBACK();
   }
}


	var querySqr = "";
	var table = "";
	var selectAction = "";
	var sqlb ="";
	var g_slbh = "";
	var slbhTagId = "";
	function queryBySlbh(slbh,zslb,frmName,slbhTagName,queryMainAction,querySqrAction,tableName,querySqrListAction){
		if (slbh == ""){
			alert("请输入受理编号!");
			return;
		}
		slbhTagId = slbhTagName;
		//clearData();
		querySqr = querySqrAction;
	    table = tableName;
	    selectAction = querySqrListAction;
	    sqlb = zslb; 
		var action = urlpath+"/rk4403.hksp::"+queryMainAction;
		var splbCode = "";
		if (document.getElementById("splb")){
			splbCode = document.getElementById("splb").value;
		}		
		var sphjCode = "";
		if (document.getElementById("sphj")){
			sphjCode = document.getElementById("sphj").value;
		}		
 		var param = "slbh="+slbh+"&splb="+splbCode+"&sphj="+sphjCode;
        remoteCallForHksp(action,"post",param,querySqrBySlbh,frmName);         
	}
	
	function querySqrBySlbh(){
		var slbh = document.getElementById(slbhTagId).value;
		if (slbh == "") {
			return;
		}
		queryProcess(slbh);
		if (document.getElementById(sqlb) && document.getElementById("zslb")){
			document.getElementById("zslb").value = document.getElementById(sqlb).value;
		}
		if (querySqr){
			var action = urlpath+ "/rk4403.hksp::"+querySqr;		
			var param = "slbh=" + slbh;
        	remoteCallForHksp(action,"post",param,querySqrList,frmName);
		}	
	}
	function querySqrList(){
		var slbh = 	document.getElementById(slbhTagId).value;
		if (slbh == ""){
			return;
		}	
		if (table && selectAction){
			var action = urlpath +"/rk4403.hksp::"+selectAction;	
			action = action+"?slbh="+ slbh;
			table.select(action);
		}
		
	}
	/*var xlh = map.get("xlh");
	if (typeof(xlh)=="undefined" || xlh == "null"){
		alert("没有受理编号为:"+g_slbh+" 的记录!");
		return "noRecord";
	}*/
	function clearData(){
		var inputs = document.getElementsByTagName("input");
　　	 	for( i = 0; i < inputs.length; i++){						
			if (inputs[i].type.toUpperCase()=="TEXT" || 
							inputs[i].type.toUpperCase()=="HIDDEN"){				
				if (inputs[i].getAttribute("clearflag") == "0"){
					inputs[i].value = "";
				}
			}
		}
		inputs = document.getElementsByTagName("table");
		for( i = 0; i < inputs.length; i++){						
			if (inputs[i].getAttribute("clearflag") == "0"){
				eval(inputs[i].getAttribute("id")+".removeAll()");
			}
		}
		if (document.getElementById("zslb")){
			document.getElementById("zslb").value = "";		
		}
		if (document.getElementById("spyj")){
			document.getElementById("spyj").value = "";	
		}
	}
	
	
    function queryProcess(slbh){
    	if (slbh ==""){
    		return;
    	}
    	var action= urlpath +"/rk4403.hksp::/spCommonModule/action/QuerySpHistory.action";
    	var queryCondition = "?zt=0&slbh="+slbh+"&splb="+document.getElementById("splb").value; 
		spHistoryList.select(action+queryCondition);	
    
    }		
	
	function QueryHistory(){
		slbh = document.getElementById(slbhTagId).value;
		if (slbh == ""){
			alert("请输入受理号!");
			return;
		}
		var action=urlpath +"/rk4403.hksp::/spCommonModule/action/QuerySpHistory.action";
		var queryCondition = "?slbh="+slbh+"&splb="+document.getElementById("splb").value; ; 
		spHistoryList.select(action+queryCondition);	
	}
	
	
	
	/***************维护查询********************************************************/
	function queryBySlbhForWh(slbh,zslb,frmName,slbhTagName,queryMainAction,querySqrAction,tableName,querySqrListAction){
		if (slbh == ""){
			alert("请输入受理编号!");
			return;
		}
		slbhTagId = slbhTagName;
		//clearData();
		querySqr = querySqrAction;
	    table = tableName;
	    selectAction = querySqrListAction;
	    sqlb = zslb; 
		var action = urlpath+"/rk4403.hksp::"+queryMainAction;
		var splbCode = "";
		if (document.getElementById("splb")){
			splbCode = document.getElementById("splb").value;
		}		
		var sphjCode = "";
		if (document.getElementById("sphj")){
			sphjCode = document.getElementById("sphj").value;
		}		
 		var param = "slbh="+slbh+"&splb="+splbCode+"&sphj="+sphjCode;
        remoteCallForHksp(action,"post",param,querySqrBySlbhForWh,frmName);         
	}
	function querySqrBySlbhForWh(){
		var slbh = document.getElementById(slbhTagId).value;
		if (slbh == "") {
			return;
		}		
		if (querySqr){
			var action = urlpath+ "/rk4403.hksp::"+querySqr;		
			var param = "slbh=" + slbh;
        	remoteCallForHksp(action,"post",param,querySqrList,frmName);
		}	
	}
	
	